﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace MadProps.Templating
{
    public class UIHintSuggestor : ITemplateSuggestor
    {
        public void SuggestTemplates(TemplateSuggestionArgs args)
        {
            // TODO not sure I like all these . dots
            var uiHint = args.Prop.PropId.ClrMember.GetCustomAttributes(false)
                .OfType<UIHintAttribute>().FirstOrDefault();

            if (uiHint != null)
            {
                args.SuggestResource(args.TargetType.Name + uiHint.UIHint);
                args.SuggestResource(uiHint.UIHint);
            }
        }
    }
}
